home *** CD-ROM | disk | FTP | other *** search
/ Die Speccy' 97 / Die Speccy' 97.iso / amiga_system / the_aminet / util / boot / snap_v2_0.lha / Snap / Patch.c < prev    next >
C/C++ Source or Header  |  1995-09-04  |  724b  |  41 lines

  1. #ifdef LATTICE
  2. typedef ULONG(*FPTR) ();
  3.  
  4. #endif
  5. #ifdef AZTEC_C
  6. typedef VOID(*FPTR) ();
  7.  
  8. #endif
  9.  
  10. IMPORT struct IntuitionBase *IntuitionBase;
  11.  
  12. #define LVOActivateWindow -0x01c2L
  13.  
  14. VOID __stdargs __saveds myActivateWindow( void);
  15.  
  16. LONG oldActivateWindow;
  17.  
  18. STATIC WORD patched = 0;
  19.  
  20. VOID SafePatch( void)
  21. {
  22.     if (!patched)
  23.     {
  24.         Forbid();    /* I don't expect interrupts to do much intuition */
  25.         oldActivateWindow = (LONG) SetFunction((struct Library *)IntuitionBase, LVOActivateWindow, (FPTR) myActivateWindow);
  26.         Permit();
  27.         patched = 1;
  28.     }
  29. }
  30.  
  31. VOID SafeRestore( void)
  32. {
  33.     if (patched)
  34.     {
  35.         Forbid();
  36.         (VOID) SetFunction((struct Library *)IntuitionBase, LVOActivateWindow, (FPTR) oldActivateWindow);
  37.         Permit();
  38.         patched = 0;
  39.     }
  40. }
  41.